﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Speech.Synthesis;

namespace WpfMedia
{
    /// <summary>
    /// SpeechSample.xaml 的交互逻辑
    /// </summary>
    public partial class SpeechSample : Page
    {
        public SpeechSample()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            System.Speech.Synthesis.SpeechSynthesizer synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
            synthesizer.SpeakAsync("东芝杭州信息机器有限公司设计中心");
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            System.Speech.Synthesis.SpeechSynthesizer synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
            synthesizer.SpeakAsync("Good Job！");
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            SpeechSynthesizer thesizer = new SpeechSynthesizer();
            PromptBuilder builder = new PromptBuilder();

            builder.AppendTextWithHint("WPF", SayAs.SpellOut);
            builder.AppendText("Sounds better than WPF");

            builder.AppendBreak(TimeSpan.FromSeconds(2));

            builder.AppendText("The time is ");
            builder.AppendTextWithHint(DateTime.Now.ToString(), SayAs.Time);

            builder.AppendBreak(TimeSpan.FromSeconds(2));

            builder.AppendText("Hay Sam,can you spell queue");
            
            builder.StartVoice("Mcirosoft Sam");
            builder.AppendTextWithHint("queue", SayAs.SpellOut);
            builder.EndVoice();

            builder.AppendText("Do it faster ");
            builder.StartVoice("Mcirosoft Sam");
            builder.StartStyle(new PromptStyle(PromptRate.ExtraFast));
            builder.AppendTextWithHint("queue", SayAs.SpellOut);
            builder.EndStyle();
            builder.EndVoice();

            thesizer.SpeakAsync(builder);
        }
    }
}
